﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WeChatBotSDK.JsonEx;

namespace WeChatBotSDK.Models.EventCallback
{
    /// <summary>
    /// 转账事件数据类
    /// </summary>
    public class TransferEventData : IWeChatEventData
    {
        /// <summary>
        /// 对方微信 ID
        /// </summary>
        [JsonPropertyName("fromWxid")]
        public string FromWxid { get; set; }

        /// <summary>
        /// 消息来源类型
        /// 1=收到转账，2=对方接收转账，3=发出转账，
        /// 4=自己接收转账，5=对方退还，6=自己退还
        /// </summary>
        [JsonConverter(typeof(StringToEnumConverter<MsgSourceEnum>))]
        [JsonPropertyName("msgSource")]
        public MsgSourceEnum MsgSource { get; set; }

        /// <summary>
        /// 转账到账类型
        /// 1=即时到账，2=延时到账
        /// </summary>
        [JsonConverter(typeof(StringToEnumConverter<TransTypeEnum>))]
        [JsonPropertyName("transType")]
        public TransTypeEnum TransType { get; set; }

        /// <summary>
        /// 转账金额，单位元
        /// </summary>
        [JsonPropertyName("money")]
        public decimal Money { get; set; }

        /// <summary>
        /// 转账备注
        /// </summary>
        [JsonPropertyName("memo")]
        public string Memo { get; set; }

        /// <summary>
        /// 转账 ID
        /// </summary>
        [JsonPropertyName("transferid")]
        public string TransferId { get; set; }

        /// <summary>
        /// 交易 ID
        /// </summary>
        [JsonPropertyName("transcationid")]
        public string TranscationId { get; set; }

        /// <summary>
        /// 转账失效时间（10 位时间戳）
        /// </summary>
        [JsonPropertyName("invalidtime")]
        public long InvalidTime { get; set; }

        /// <summary>
        /// 消息 ID
        /// </summary>
        [JsonPropertyName("msgId")]
        public string MsgId { get; set; }

        /// <summary>
        /// 获取失效时间的日期时间格式
        /// </summary>
        [JsonIgnore(Condition = JsonIgnoreCondition.Always)] 
        public DateTime InvalidTimeAsDateTime => DateTimeOffset.FromUnixTimeSeconds(InvalidTime).DateTime;
    }
}
